# -*- coding: utf-8 -*-

import time

from selenium import webdriver
from selenium.webdriver import ActionChains
from selenium.webdriver.common.by import By

driver = webdriver.Chrome()
driver.maximize_window()
driver.get('https://passport.vip.com/login?src=https%3A%2F%2Fwww.vip.com%2F')
time.sleep(2)
# 切换登录方式
driver.find_element(By.XPATH,'//div[@class="c-tab-nav "]/div[2]').click()

# 页面加载时间
time.sleep(0.5)
driver.find_element(By.ID, 'J_login_name').send_keys('1531343133531')
driver.find_element(By.ID, 'J_login_pwd').send_keys('adfasdfad')

time.sleep(0.5)
# 勾选
label = driver.find_element(By.ID, 'J_login_agree')
# label.click()
driver.execute_script('arguments[0].click();', label)  # js代码的点击方法

# 点击登录按钮
driver.find_element(By.ID, 'J_login_submit').click()
time.sleep(2)

# 定位验证码图片
img = driver.find_element(By.CLASS_NAME, 'vipsc_qimg')

time.sleep(1)
# 创建动作链对象
action = ActionChains(driver)
# 移动到对应的元素上面去
action.move_to_element(img)
# 最后要触发执行
action.perform()


